package com.neu.his.controller.SystemManage01.UserManage;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neu.his.core.Result;
import com.neu.his.entity.Role;
import com.neu.his.entity.VO.SystemManage01.UserManage.RoleVO;
import com.neu.his.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: neu-his
 * <p>
 * Created by 31316 on 2020/7/16 13:57
 */
@RestController
@RequestMapping("/role")
public class RoleManageController {
    @Autowired
    RoleMapper roleMapper;

    @GetMapping("/all")
    public Result<List<RoleVO>> getall() {
        QueryWrapper<Role> queryWrapper=new QueryWrapper<>();
        List<Role> list = roleMapper.selectList(queryWrapper.ne("remove_mark",1L));
        List<RoleVO> result = new ArrayList<>();
        for (Role role :list) {
            RoleVO roleVO=new RoleVO();
            roleVO.setId(role.getId());
            roleVO.setName(role.getName());
            result.add(roleVO);
        }
        return Result.success(result);
    }

}
